In a wireless communications network, if a terminal device cannot be served by a cell of a base station, for example, the terminal device is not located in signal coverage of the base station, the terminal device is located in a hole area of signal coverage of the base station, or a base station fault causes a failure in providing signal coverage for the terminal device, in these cases, the terminal device may access, by using a terminal device served by a cell of the base station or another base station, a target device in a network to perform data transmission. Such a terminal device that is served by the cell of the base station or the another base station is referred to as cell function user equipment (CF UE), and such a terminal device that accesses the target device in the network by using the CF UE is referred to as access user equipment (AC UE). In a device to device (D2D) protocol, an AC UE may discover a CF UE by detecting a channel of another terminal device. However, in the D2D protocol, terminal devices use their capabilities to contend for network resources, and a terminal device with a stronger capability occupies more network resources or preferentially occupies a network resource. However, it is possible that the CF UE that can provide a service of accessing a network for the AC UE cannot obtain enough network resources, which causes a case in which the AC UE cannot discover the CF UE or the AC UE discovers the CF UE but cannot access the target device in the network. For example, a CF UE that is far from the AC UE occupies a large quantity of network resources by contention, the AC UE cannot detect the CF UE due to a long distance, and a CF UE that is closer to the AC UE cannot provide a service for the AC UE either, due to a failure in acquiring enough network resources, and resource waste is caused and user experience of the AC UE is degraded.